package com.pand.model.zmxy;

import com.pand.model.BaseObject;
import com.pand.model.customer.Customer;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * 
 * @ClassName: CstExt
 * @Description: 芝麻信用
 *
 */
@Entity
@Table(name = "CST_EXT")
@SequenceGenerator(name = "SEQ_CST_EXT", sequenceName = "SEQ_CST_EXT", allocationSize = 1)
public class CstExt extends BaseObject {
	
	/**
	 * @Fields serialVersionUID :
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 主键
	 */
	private Long id;
	
	/**
	 *  客户实体
	 */
	private Customer customer;
	
	/**
	 *  授权类型 0:芝麻信用，1:有押金，2:押金+芝麻信用
	 */
	private String authType;
	
	/**
	 *  芝麻分
	 */
	private String zmScore;
	
	/**
	 *  授权状态0:失败，1:成功
	 */
	private String authStatus;
	
	/**
	 *  芝麻授权状态0：失败，1：成功
	 */
	private String zmAuthStatus;
	
	/**
	 *  芝麻会员在商户的身份标识
	 */
	private String openId;
	
	/**
	 *  创建时间
	 */
	private Timestamp createTime;
	
	/**
	 *  修改时间
	 */
	private Timestamp updateTime;
	
	/**
	 *  授权类型名称
	 */
	private String authTypeName;
	
	/**
	 *  租车授权状态
	 */
	private String authStatusName;
	
	/**
	 *  芝麻授权状态
	 */
	private String zmAuthStatusName;

	@Transient
	public String getAuthTypeName() {
		if (ZmConstants.AUTHTYPE_ZM.equals(authType)) {
			authTypeName = "芝麻信用";
		} else if (ZmConstants.AUTHTYPE_DEPOSIT.equals(authType)) {
			authTypeName = "押金";
		} else if (ZmConstants.AUTHTYPE_DPT_ZM.equals(authType)) {
			authTypeName = "押金&芝麻信用";
		} else {
			authTypeName = "";
		}
		return authTypeName;
	}

	public void setAuthTypeName(String authTypeName) {
		this.authTypeName = authTypeName;
	}

	@Transient
	public String getAuthStatusName() {
		if (authType != null && ZmConstants.AUTHSTATUS_S.equals(authStatus)) {
			authStatusName = "成功";
		} else if (authType != null
				&& ZmConstants.AUTHSTATUS_F.equals(authStatus)) {
			authStatusName = "失败";
		} else {
			authStatusName = "";
		}
		return authStatusName;
	}

	public void setAuthStatusName(String authStatusName) {
		this.authStatusName = authStatusName;
	}

	@Transient
	public String getZmAuthStatusName() {
		if (authType != null && ZmConstants.ZMAUTHSTATUS_S.equals(zmAuthStatus)) {
			zmAuthStatusName = "成功";
		} else if (authType != null
				&& ZmConstants.ZMAUTHSTATUS_F.equals(zmAuthStatus)) {
			zmAuthStatusName = "失败";
		} else {
			zmAuthStatusName = "";
		}
		return zmAuthStatusName;
	}

	public void setZmAuthStatusName(String zmAuthStatusName) {
		this.zmAuthStatusName = zmAuthStatusName;
	}

	@Id
	@GeneratedValue(generator = "SEQ_CST_EXT")
	@Column(name = "ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
	@JoinColumn(name = "CST_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name = "AUTH_TYPE")
	public String getAuthType() {
		return authType;
	}

	public void setAuthType(String authType) {
		this.authType = authType;
	}

	@Column(name = "ZM_SCORE")
	public String getZmScore() {
		return zmScore;
	}

	public void setZmScore(String zmScore) {
		this.zmScore = zmScore;
	}

	@Column(name = "AUTH_STATUS")
	public String getAuthStatus() {
		return authStatus;
	}

	public void setAuthStatus(String authStatus) {
		this.authStatus = authStatus;
	}

	@Column(name = "OPEN_ID")
	public String getOpenId() {
		return openId;
	}

	public void setOpenId(String openId) {
		this.openId = openId;
	}

	@Column(name = "CREATE_TIME")
	public Timestamp getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@Column(name = "UPDATE_TIME")
	public Timestamp getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "ZM_AUTH_STATUS")
	public String getZmAuthStatus() {
		return zmAuthStatus;
	}

	public void setZmAuthStatus(String zmAuthStatus) {
		this.zmAuthStatus = zmAuthStatus;
	}

}
